#pragma once
//#pragma comment(lib,"corona")

#include "Globals.h"
#include "Rect.h"

namespace game_engine { namespace open_gl 
{

//CONSTANTS:

typedef enum {
	kGLTexture2DPixelFormat_Automatic = 0,
	kGLTexture2DPixelFormat_RGBA8888,
	kGLTexture2DPixelFormat_RGB565,
	kGLTexture2DPixelFormat_A8,
} GLTexture2DPixelFormat;


/*!
 * \class GLTexture2D
 * \brief This class allows to easily create OpenGL 2D textures from images, 
 * text or raw data.
 * \details The created GLTexture2D object will always have power-of-two 
 * dimensions. Depending on how you create the GLTexture2D object, the actual 
 * image area of the texture might be smaller than the texture dimensions 
 * i.e. "contentSize" != (pixelsWide, pixelsHigh) and (maxS, maxT) != (1.0, 1.0)
 * Be aware that the content of the generated textures will be upside-down!
 */
class GLTexture2D
{
///////////////////////////////////////////////////////////////////////////////
// Attribute definition
///////////////////////////////////////////////////////////////////////////////
protected:
   	GLuint name;
    string fileName;
    void *data;
    utils::Size	contentSize;
	UINT32 pixelsWide;
    UINT32 pixelsHigh;
	GLTexture2DPixelFormat pixelFormat;
	GLfloat maxS;
	GLfloat	maxT;

///////////////////////////////////////////////////////////////////////////////
// Method definition
///////////////////////////////////////////////////////////////////////////////
public:
    // Constructors and destructors
    GLTexture2D(void);
    GLTexture2D(void *d, const GLTexture2DPixelFormat pf, const UINT32 pw, 
        const UINT32 ph, const utils::Size &s);
    GLTexture2D(const string &file, const INT32 type);
    virtual ~GLTexture2D(void);

    // Others
    void initialize(void) throw(...);    
    void drawAtPoint(const utils::Point &point);
    void drawAtPoint(const utils::Point &point, const FLOAT32 rotation, 
        const FLOAT32 scale = 1.0f);
    void drawInRect(const utils::Rect &dest, const utils::Rect &src, 
        const FLOAT32 rotation = 0.0f, const FLOAT32 scale = 1.0f);
    void drawInRect(const utils::Rect &rect);
    void drawInVertices(const GLfloat* vertices);

    // Getters
    const GLuint getName(void) const;
    const utils::Size getContentSize(void) const;
    const UINT32 getPixelsWide(void) const;
    const UINT32 getPixelsHigh(void) const;
    const GLTexture2DPixelFormat getPixelFormat(void) const;
    const GLfloat getMaxS(void) const;
    const GLfloat getMaxT(void) const;
    const FLOAT32 getWidth(void) const;
    const FLOAT32 getHeight(void) const;

    // Setters
    void setName(const GLuint n);
    void setFileName(const string &file);
    void setContentSize(const utils::Size &s);
    void setPixelsWide(const UINT32 pw);
    void setPixelsHigh(const UINT32 ph);
    void setPixelFormat(const GLTexture2DPixelFormat pf);
    void setMaxS(const GLfloat m);
    void setMaxT(const GLfloat m);  

};

}}
